﻿using FluentScheduler;

namespace ScheduleDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            JobManager.Initialize(new CronRegistry());
            var job = new JobService();
            job.Start();
            Console.ReadKey();
        }
    }

    internal class CronRegistry : Registry
    {
        public CronRegistry()
        {
            Schedule<Job1>().ToRunOnceIn(5).Seconds();
            Schedule<Job2>().ToRunEvery(5).Seconds();
        }
    }

    internal class Job1 : IJob
    {
        public void Execute()
        {
            Console.WriteLine($"job1. {DateTime.Now:HH:mm:ss}");
        }
    }

    internal class Job2 : IJob
    {
        public void Execute()
        {
            Console.WriteLine($"job2. {DateTime.Now:HH:mm:ss}");
        }
    }
}
